import { _decorator, Component, Label, Node, UIMeshRenderer } from 'cc';
import { UIMgr } from '../Mgr/UIMgr';
import { AssetList } from '../Global';
import { AudioMgr, SoundName } from '../Mgr/AudioMgr';
import { LocalStorageMgr } from '../Mgr/LocalStorageMgr';
import { GAME_MODE, GAMEDATA } from '../GameScene/GAMEDATA';
import { GameSet } from '../Pop/GameSet';
import { GameShop } from '../Pop/GameShop';
const { ccclass, property } = _decorator;

@ccclass('LoginScene')
/**
 * 游戏首页
 */
export class LoginScene extends Component {

    //金币数量
    @property(Label)
    private coin: Label = null;

    //游戏分数
    @property(Label)
    private BestScore: Label = null;

    protected start(): void {
        this.BestScore.string = LocalStorageMgr.Instance.LOCAL_STORAGE_DATA.BESTSCORE.toString();
        this.UpdateCoin();
    }

    /**
     * 更新金币
     */
    public UpdateCoin() {
        this.coin.string = LocalStorageMgr.Instance.LOCAL_STORAGE_DATA.COIN.toString();
    }

    /**
     * 点击开始游戏
     */
    private StartClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);
        UIMgr.Instance.UdpateScene(AssetList.Scene.GameScene);
    }

    /**
     * 点击设置
     */
    private SetClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);
        let set: Node = UIMgr.Instance.ShowPop(AssetList.Pop.GAMESET);
        set.getComponent(GameSet).Init(true);
    }

    /**
     * 点击更多游戏
     */
    private MoreClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);

    }

    /**
     * 点击记录按钮
     */
    private ShopClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);
        let gr: Node = UIMgr.Instance.ShowPop(AssetList.Pop.GAMESHOP);
        gr.getComponent(GameShop).UpdateShop();
        gr.getComponent(GameShop).Cb = this.UpdateCoin.bind(this);
    }

}


